package com.p595263720.o_amap.search.model;

import com.amap.api.services.core.PoiItem;
import com.amap.api.services.core.SuggestionCity;
import com.amap.api.services.poisearch.PoiResult;
import com.amap.api.services.poisearch.PoiSearch;

import java.util.ArrayList;
import java.util.List;

public class UnifiedPoiResult {
    /// 返回的POI数目 [Android, iOS]
    int pageCount;

    /// 请求参数 [Android]
    PoiSearch.Query query;

    /// 搜索边界 [Android]
    UnifiedSearchBound bound;

    /// POI结果，AMapPOI 数组 [Android, iOS]
    List<UnifiedPoiItem> pois = new ArrayList<UnifiedPoiItem>();

    /// 城市建议列表 [Android, iOS]
    List<UnifiedSuggestionCity> searchSuggestionCitys = new ArrayList<UnifiedSuggestionCity>();

    /// 关键字建议列表 [Android, iOS]
    List<String> searchSuggestionKeywords = new ArrayList<String>();

    public UnifiedPoiResult(PoiResult result) {
        this.pageCount = result.getPageCount();
        query = result.getQuery();
        this.bound = new UnifiedSearchBound(result.getBound());
        ArrayList<PoiItem> poItem = result.getPois();
        if (poItem != null) {
            for (PoiItem poiItem : poItem) {
                pois.add(new UnifiedPoiItem(poiItem));
            }
        }
        List<SuggestionCity> cityList = result.getSearchSuggestionCitys();
        if (cityList != null) {
            for (SuggestionCity suggestionCity : cityList) {
                searchSuggestionCitys.add(new UnifiedSuggestionCity(suggestionCity));
            }
        }
        searchSuggestionKeywords = result.getSearchSuggestionKeywords();
    }
}
